
from sqlalchemy import Column, Integer, String, Boolean, DECIMAL, BigInteger
from sqlalchemy.ext.declarative import declarative_base

# SQLAlchemy模型
Base = declarative_base()


class UserInfo(Base):
    """用户信息模型"""
    __tablename__ = 'user_info'

    id = Column(Integer, primary_key=True, comment='用户ID')
    name = Column(String(50), comment='姓名')
    code = Column(String(20), index=True, comment='学号')
    gender = Column(Integer, comment='性别：1-男，2-女')
    mobile = Column(String(20), index=True, comment='手机号')
    mail = Column(String(100), comment='邮箱')
    avatar = Column(String(255), comment='头像URL')
    cardPhoto = Column('card_photo', String(255), comment='证件照片')
    ethnic = Column(String(20), comment='民族')
    ethnicId = Column('ethnic_id', Integer, comment='民族ID')
    politics = Column(Integer, comment='政治面貌ID')
    politicsName = Column('politics_name', String(50), comment='政治面貌名称')
    schoolId = Column('school_id', Integer, index=True, comment='学校ID')
    schoolName = Column('school_name', String(100), comment='学校名称')
    schoolShortName = Column('school_short_name', String(50), comment='学校简称')
    collegeName = Column('college_name', String(100), comment='学院名称')
    majorName = Column('major_name', String(100), comment='专业名称')
    className = Column('class_name', String(50), comment='班级名称')
    grade = Column(Integer, comment='年级')
    score = Column(DECIMAL(10, 2), comment='分数')
    hours = Column(DECIMAL(10, 2), comment='学时')
    hourUnit = Column('hour_unit', Integer, comment='学时单位')
    credit = Column(DECIMAL(10, 2), comment='学分')
    integral = Column(Integer, comment='积分')
    identity = Column(Integer, comment='身份：1-学生')
    status = Column(Integer, comment='状态：1-正常')
    isCreateActivity = Column('is_create_activity', Integer, comment='是否可创建活动')
    isReceive = Column('is_receive', Integer, comment='是否接收通知')
    isOpenHonorJoinNumber = Column('is_open_honor_join_number', Integer, comment='是否开放荣誉加入数')
    noFaithNum = Column('no_faith_num', Integer, comment='失信次数')
    faithUpdateTime = Column('faith_update_time', BigInteger, comment='信用更新时间')
    lastLoginTime = Column('last_login_time', BigInteger, comment='最后登录时间')
    organizationName = Column('organization_name', String(100), comment='组织名称')
    waysConvert = Column('ways_convert', Integer, comment='转换方式')
    transferMajorStatus = Column('transfer_major_status', Integer, comment='转专业状态')
    transferMajorApplyId = Column('transfer_major_apply_id', Integer, comment='转专业申请ID')
    countryCode = Column('country_code', String(10), comment='国家代码')
    logo = Column(String(255), comment='Logo URL')
    appWebsiteNavTitle = Column('app_website_nav_title', String(50), comment='应用网站导航标题')
    personTag = Column('person_tag', String(500), comment='用户标签，JSON格式')

    def __repr__(self):
        return f"<UserInfo(id={self.id}, name={self.name}, code={self.code})>"